package top.juntech.msweathercollection.config;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.juntech.msweathercollection.job.WeatherDataSyncJob;
//import top.juntech.singleweatherforecastsys.job.WeatherDataSyncJob;

@Configuration
public class QuartzConfig {
//    JobDetail
    @Bean
    public JobDetail weatherDataSyncJobJobDetail(){
        return JobBuilder.newJob(WeatherDataSyncJob.class).withIdentity("weatherDataSyncJob")
                .storeDurably().build();

    }

//    Trigger
    @Bean
    public Trigger weatherDataSyncTrigger(){
//        半小时拉取一次数据服务
        SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1800).repeatForever();
        return TriggerBuilder.newTrigger().forJob(weatherDataSyncJobJobDetail())
                .withIdentity("trigger").withSchedule(simpleScheduleBuilder).build();
    }
}
